import { createParamDecorator, ExecutionContext } from '@nestjs/common';

export const AuthToken = createParamDecorator((data: unknown, ctx: ExecutionContext): string => {
  const request = ctx.switchToHttp().getRequest();
  let token = request.headers['authorization'];
  if (token?.startsWith('Bearer')) {
    token = token.substring(6).trim();
  } else {
		token = null;
	}
  return token;
});
